{% extends 'base.html' %}
{% block title %}
    问卷调查
{% endblock %}
{% block content %}
{#    <div class="layui-progress layui-progress-big" lay-filter="demo" lay-showPercent="true">#}
{#		<div class="layui-progress-bar layui-bg-blue" lay-percent="1%"></div>#}
{#	</div>#}
    <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 30%">
        <div class="layui-tab-item layui-show">
            <form class="layui-form layui-form-pane" action="" method="post">
                <div class="layui-form-item" style="padding: 0% 30%"> <div class="layui-form-mid layui-word-aux">{{ test_message }}</div></div>
                    {% for question in question_list %}
                        <div class="layui-row layui-col-space10 layui-form-item">
                        <label class="layui-form-text">{{ question }}</label>
                        <div class="layui-input-block">
                        <input type="radio"  name="{{ forloop.counter }}" lay-verify="otherReq" value="1" title="是" />
                        <input type="radio" name="{{ forloop.counter }}" lay-verify="otherReq" value="0" title="否" />
                        </div>
                        </div>
                    {% endfor %}
                <div class="layui-form-item" style="padding: 20px 30%;"><button class="layui-btn">提交</button></div>
            </form>
        </div>
    </div>
    <script>
    layui.use(['form'], function() {
        var form = layui.form;



 //自定义验证规则
  form.verify({
    otherReq: function(value,item){
      var $ = layui.$;
      var verifyName=$(item).attr('name')
      , verifyType=$(item).attr('type')
      ,formElem=$(item).parents('.layui-form')//获取当前所在的form元素，如果存在的话
,verifyElem=formElem.find('input[name='+verifyName+']')//获取需要校验的元素
,isTrue= verifyElem.is(':checked')//是否命中校验
,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
if(!isTrue || !value){
        //定位焦点
        focusElem.css(verifyType=='radio'?{"color":"#FF5722"}:{"border-color":"#ff5722"});
        //对非输入框设置焦点
        focusElem.first().attr("tabIndex","1").css("outline","0").blur(function() {
            focusElem.css(verifyType=='radio'?{"color":""}:{"border-color":""});
         }).focus();
        return '必填项不能为空';
}
    }
  });

    });
    </script>
{% endblock %}
